<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>会员列表-后台管理系统-Admin 1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/weadmin.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="weadmin-nav">
			<span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">会员管理</a>
        <a>
          <cite>会员列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">&#x1002;</i></a>
</div>
<div class="weadmin-body">
    <div class="layui-row" align="center">
        <form class="layui-form layui-col-md12 we-search" onsubmit="return false;">
            搜索：
            <div class="layui-inline">
                <input type="text" id="uname" name="uname" placeholder="请输入用户名" autocomplete="off"
                       class="layui-input">
            </div>
            <button class="layui-btn" lay-submit="" lay-filter="search" data-type="reload"><i class="layui-icon">&#xe615;</i>
            </button>
        </form>
    </div>
    <div class="weadmin-block demoTable" align="right">
       <%-- <button class="layui-btn layui-btn-danger" data-type="getCheckData"><i class="layui-icon">&#xe640;</i>批量删除
        </button>--%>

<%--
        <button class="layui-btn"  onclick="WeAdminShow('添加用户','./add',600,400)"><i class="layui-icon" ></i>添加</button></a>
--%>

    </div>
    <table id="demo" lay-filter="test"></table>
    <script type="text/html" id="barDemo" >        <a class="layui-btn layui-btn-xs" lay-event="edit" >编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" data-type="getCheckData">删除</a>
    </script>
<script type="text/javascript">
    layui.extend({
        admin: '${pageContext.request.contextPath}/static/js/admin'
    });
    layui.use(['table','jquery','admin'], function(){
        var table = layui.table;
        var $=layui.jquery;
        table.render({
            elem: '#demo'
            ,height: 315
            ,url: '../user' //数据接口
            ,page: true //开启分页
            ,cols: [[ //表头
                /* {type: 'checkbox'},*/
                {field: 'uid', title: 'ID'},
                {field: 'uname', title: '用户名'},
                {field: 'uemail', title: '邮箱'},
                {field: 'utel', title: '手机号码'},
                {field: 'sex', title: '性别'},
                {field: 'onshow', title: '是否在播放'}
                , {fixed: 'right', title: '操作', width: 150, align: 'center', toolbar: '#barDemo'}
            ]]
        });


        $('.weadmin-body .layui-btn').on('click',function () {
            var type= $(this).data('type');
            active[type]?active[type].call(this):'';
        });
        var active={
            reload:function () {
                var uname = $("#uname").val();
                if($.trim(uname).length>0){
                    table.reload('demo',{
                        page:{curr:1},
                        where:{uname:uname}
                    });
                }
            }

        }



    table.on('tool(test)',function(obj){

        var data =obj.data;
        var event = obj.event;
        console.log(data);
        if(event == 'del'){
            $.ajax({
                url:"../item/del",
                data:{"uid":data.uid},
                dataType:"text",
                success:function(d){
                    if(d=="true"){
                        $(".layui-laypage-btn").click();
                    }
                },
                type:"post"
            });
        }else if (event=='edit') {

            window.location.href="${pageContext.request.contextPath}/user/add?"+"uid="+data.uid;
        }
    });
    });
</script>

</body>
</html>